#include "Logic.h"

vector<int> Logic::searchResultIndices;
Task* Logic::selectedTask = NULL;

//@author A0105566E
//The logic class is in charge of most of the data manipulation in Keyboard warrior. It passes
//user inputs to the parser class for processing before carrying out the neccessary operations.
//It also acts as a facade for the task list class, calling the corresponding functions in the 
//task list class for certain operations.



//This function is called when the program first starts
//It will load file and output the summary of the task
void Logic::initiate(string &result)
{
	loadFile();
	Date::updateSevenDaysLater();
	getTaskSummary(result);
}


//@author A0101856J
CommandType Logic::executeCommand(string userCommand, string& result)
{
	int updated;
	vector<string> parameters;
	CommandType action;
	
	Parser::splitString(userCommand,parameters);
	Date::updateSevenDaysLater(); // in case time has passed to the next day
	result = "";

	if (selectedTask != NULL) {
		updated=editTask(selectedTask,parameters,result);
		action = UPDATE;
	}
	else {
		action = Parser::parseCommandType(parameters[0]);
		if (action != SUMMARY && action != UNDO && action != REDO && action != DISPLAY) {
			if (parameters.size() <= 1 || parameters[1] == "") {
				result = MESSAGE_ERROR_INVALID_INPUTS;
				return action;
			}
		}

		switch (action)
		{
		case SUMMARY:
			getTaskSummary(result);
			break;
		case ADD:
			addTask(parameters, result);
			break;
		case DELETE:
			deleteTask(parameters, result); 
			break;
		case UPDATE:
			editTask(parameters, result);
			break;
		case MARK:
			setTaskDone(parameters[1], true, result);
			break;
		case UNMARK:
			setTaskDone(parameters[1], false, result);
			break;
		case UNDO:
			if (History::undoPreviousCommand() == ERROR_PROCESSING_COMMAND) {
				result = MESSAGE_UNDO_FAILURE;
			}
			else {
				result = MESSAGE_UNDO_SUCCESS;
			}
			saveFile();
			break;
		case REDO:
			if (History::redoPreviousCommand() == ERROR_PROCESSING_COMMAND) {
				result = MESSAGE_REDO_FAILURE;
			}

			else {
				result = MESSAGE_REDO_SUCCESS;
			}
			saveFile();
			break;
		case SEARCH:
			searchTasks(parameters[1]);
			displaySearchResults(result);
			break;
		case DISPLAY:
			TaskType type;
			int index;
			if (parameters.size() > 1 && Parser::parseTaskTypeAndIndex(parameters[1], type, index)) {
				if(TaskList::getTaskOfTypeAt(type, index)==NULL)
					result=MESSAGE_INVALID_COMMAND;
				else 
				{
					selectedTask=TaskList::getTaskOfTypeAt(type, index);
					displayIndividualTask(selectedTask, result);
				}
			}
			else if(parameters.size() > 1 && parameters[1]=="latest task")
			{
				displayIndividualTask(TaskList::getLatestTask(),result);
				if(TaskList::getLatestTask()!=NULL)
				{
					selectedTask=TaskList::getLatestTask();
				}
			}
			else
				displayTask(result);
			break;
		default:
			break;
		}
	}
	if (action != SEARCH &&action!=DELETE) {
		resetBuffer();
	}

	return action;
}

//@author A0096794H
int Logic::addTask(vector<string> parameters, string& result)
{
	assert(parameters.size()!=0);

	vector<Date> dates;
	vector<Time> times;
	Date date;
	Time time;
	for (unsigned int i=2; i<parameters.size(); i++) {
		string str = parameters[i];
		date = Parser::parseDate(str);
		time = Parser::parseTime(str);
		if (date != NULL_DATE) {
			dates.push_back(date);
		}
		else if (time != NULL_TIME) {
			times.push_back(time);
		}
	}

	Task * newTask = NULL;

	if (dates.size() == 0 && times.size() == 0) {
		newTask = new FloatingTask(parameters[1]);
	}
	else if (dates.size() == 1 && times.size() == 0) {
		newTask = new DeadlineTask(parameters[1], dates[0]);
	}
	else if (dates.size() == 2 && times.size() == 0) {
		if (dates[0] < dates[1])
			newTask = new TimedTask(parameters[1], dates[0], dates[1]);
	}
	else if (dates.size() == 1 && times.size() == 1) {
		newTask = new DeadlineTask(parameters[1], dates[0], times[0]);
	}
	else if (dates.size() == 1 && times.size() == 2) {
		if (times[0] < times[1])
			newTask = new TimedTask(parameters[1], dates[0], times[0], times[1]);
	}
	else if (dates.size() == 2 && times.size() == 2) {
		if ((dates[0] < dates[1]) || (dates[0] == dates[1]) && (times[0] < times[1])) 
			newTask = new TimedTask(parameters[1], dates[0], times[0], dates[1], times[1]);
	}

	if (newTask != NULL) {
		TaskList::addTask(newTask);
		History::storeAction(ADD, newTask);
		result = MESSAGE_ADD_SUCCESS;
		saveFile();
		return SUCCESS;
	}
	else {
		result = MESSAGE_ADD_ERROR+MESSAGE_CHECK_USER_GUIDE;
		return ERROR_PROCESSING_COMMAND;
	}
}

//@author A0105566E

//This function is to delete tasks
//When multiple matching results are  found
//It will store the results inside the vector searchResultIndice
//When user delete again this storage will be cleared


int Logic::deleteTask(vector<string> parameters, string& result)
{

	Task *deletedTask = NULL;
	TaskType type;
	int index;

	if (Parser::isPositiveInteger(parameters[1]))
	{
		unsigned int i = stoi(parameters[1]);
		if (i <= searchResultIndices.size()) {
			int index = searchResultIndices[i-1];
			deletedTask = TaskList::deleteTaskAt(index);
		}
	}
	else if (Parser::parseTaskTypeAndIndex(parameters[1], type, index))
	{
		deletedTask = TaskList::deleteTaskOfTypeAt(type, index);
	}
	else {
		int numResults = Logic::searchTasks(parameters[1]);
		if (numResults == 0)
		{
			result = MESSAGE_NO_MATCH_RESULT;
			return ERROR_PROCESSING_COMMAND;
		}
		if (numResults == 1)
		{
			int index = searchResultIndices[0];
			deletedTask = TaskList::deleteTaskAt(index);
		}
		else if (numResults > 1)
		{
			result = "The candidate solutions are: \n";
			for (int i=0; i<numResults; i++)
			{
				int index = searchResultIndices[i];
				result += to_string(i+1) + ". " + TaskList::getTaskAt(index)->format() + "\n";
			}
			return SUCCESS;
		}
	}

	if (deletedTask != NULL) {
		result = MESSAGE_DELETE_SUCCESS;
		if(TaskList::getLatestTask()==deletedTask)
		{
			TaskList::setLatestTask(NULL);
		}
		History::storeAction(DELETE, deletedTask);
		resetBuffer();
		saveFile();
		return SUCCESS;
	}
	else {
		result = MESSAGE_UNKNOWN_ERROR_ILLEGAL;
		return ERROR_PROCESSING_COMMAND;
	}
}

//@author A0096794H
//This is for an individual task
int Logic::editTask(Task* task,vector<string> parameters,string& result)
{
	Task * newTask = NULL;
	static string desc;
	static Date startDate=NULL_DATE, endDate=NULL_DATE;
	static Time startTime=NULL_TIME, endTime=NULL_TIME;
	static bool done, flag = true;
	bool errorFlag = false;

	if (flag) {
		desc = selectedTask->getDescription();
		done = selectedTask->isDone();
		if (selectedTask->getTaskType() == DEADLINE) {
			DeadlineTask* dTask = ((DeadlineTask *) selectedTask);
			endDate = dTask->getDueDate();
			endTime = dTask->getDueTime();
			startDate = NULL_DATE;
			startTime = NULL_TIME;
		}
		else if (selectedTask->getTaskType() == TIMED) { 
			TimedTask* tTask = ((TimedTask *) selectedTask);
			startDate = tTask->getStartDate();
			endDate = tTask->getEndDate();
			startTime = tTask->getStartTime();
			endTime = tTask->getEndTime();
		}
		else {
			startDate = endDate = NULL_DATE;
			startTime = endTime = NULL_TIME;
		}
		flag = false;
	}

	if(parameters[0]=="1"&&parameters.size()>1&&parameters[1]!="")
		desc=parameters[1];
	else if(parameters[0]=="2"&&parameters.size()>1)
		startDate = Parser::parseDate(parameters[1]);
	else if(parameters[0]=="3"&&parameters.size()>1)
		startTime = Parser::parseTime(parameters[1]);
	else if(parameters[0]=="4"&&parameters.size()>1)
		endDate = Parser::parseDate(parameters[1]);
	else if(parameters[0]=="5"&&parameters.size()>1)
		endTime = Parser::parseTime(parameters[1]);
	else if (parameters[0]=="6")
		done = !done;
	else if(parameters[0]=="7") {
		flag=isValidTask(desc,startDate,startTime,endDate,endTime,newTask);
		if (done && newTask != NULL) {
			newTask->markDone();
		}
	}
	else if(parameters[0]=="8")
	{
		selectedTask=NULL;
		result="";
		flag=true;
		return SUCCESS;
	}
	else {
		errorFlag=true;
	}

	displayEditedTask(desc,startDate,startTime,endDate,endTime,done,result);

	if(flag)
	{
		History::storeAction(UPDATE,selectedTask,newTask);
		TaskList::updateTask(selectedTask,newTask);
		selectedTask=NULL;
		result="";
		saveFile();
		flag=true;
		return SUCCESS;
	}
	else if(errorFlag)
	{
		result+=MESSAGE_ERROR_INVALID_INPUTS;
		return ERROR_PROCESSING_COMMAND;
	}
	else if(parameters[0] == "7") {
		result+=MESSAGE_ERROR_MISMATCHED_TASKS;
		result+=MESSAGE_CHECK_USER_GUIDE;
		return ERROR_PROCESSING_COMMAND;
	}
	else {
		return SUCCESS;
	}
}

//@author A0096794H
//This is to search and identify the list of tasks that matches the task to be edited
int Logic::editTask(vector<string> parameters, string& result)
{
	TaskType type;
	int index;
	if (Parser::isPositiveInteger(parameters[1]))
	{
		unsigned int i = stoi(parameters[1]);
		if (i <= searchResultIndices.size()) {
			int index = searchResultIndices[i-1];
			selectedTask = TaskList::getTaskAt(index);
			displayIndividualTask(selectedTask, result);
		}
		else {
			result = MESSAGE_NO_MATCH_RESULT;
			return ERROR_PROCESSING_COMMAND;
		}
		
	}
	else if (Parser::parseTaskTypeAndIndex(parameters[1], type, index))
	{
		selectedTask= TaskList::getTaskOfTypeAt(type,index);
		if(selectedTask!=NULL)
			displayIndividualTask(selectedTask,result);
		else
			return ERROR_PROCESSING_COMMAND;
	}
	else
	{
		searchTasks(parameters[1]);
		if(searchResultIndices.size()==0)
		{
			result=MESSAGE_SEARCH_ZERO_RESULTS;
		}
		else if(searchResultIndices.size()==1)
		{
			Task* task;
			task=TaskList::getTaskAt(searchResultIndices[0]);
			selectedTask=task;
			displayIndividualTask(task,result);
		}
		else
		{
			displaySearchResults(result);
		}
	}
	return SUCCESS;
}
//@author A0105566E

CommandType Logic::displayTask(string &result)
{
	int floatingTaskCounter=0;
	int deadlineTaskCounter=0;
	int timedTaskCounter=0;

	result = "";
	result += MESSAGE_PARTITION_1;
	result += "Floating tasks: \n\n";

	for (int i=0; i<TaskList::totalTaskCount(); i++)
	{
		Task* task = TaskList::getTaskAt(i);
		if (TaskList::getTaskAt(i)->getTaskType() == FLOATING)
		{
			stringstream ss;
			ss <<"F"<<floatingTaskCounter+1 << "." << task->format();
			if (task->isDone()) {
				ss << MESSAGE_DONE;
			}
			ss << endl;
			result+=ss.str();
			floatingTaskCounter++;
		}
	}

	result +=MESSAGE_PARTITION_2;
	result += "Deadline tasks: \n\n";

	for (int i=0; i<TaskList::totalTaskCount(); i++)
	{
		Task* task = TaskList::getTaskAt(i);

		if(task->getTaskType() == DEADLINE)
		{
			stringstream ss;
			ss <<"D"<<deadlineTaskCounter + 1 << "." << task->format();
			if (task->isDone()) {
				ss <<MESSAGE_DONE;
			}
			ss << endl;
			result+=ss.str();
			deadlineTaskCounter++;
		}
	}

	result +=MESSAGE_PARTITION_2;
	result += "Timed tasks: \n\n";

	for(int i=0; i<TaskList::totalTaskCount(); i++)
	{
		Task* task = TaskList::getTaskAt(i);
		if(task->getTaskType() == TIMED)
		{
			stringstream ss;
			ss <<"T"<<timedTaskCounter + 1 << "." << task->format();
			if (task->isDone()) {
				ss << " (done)";
			}
			ss << endl;
			result+=ss.str();
			timedTaskCounter++;
		}
	}

	result += MESSAGE_PARTITION_2;
	result += MESSAGE_PARTITION_1;
	return DISPLAY;
}

//@author A0099619J
int Logic::setTaskDone(string desc, bool mark, string& result) {
	Task* markedTask = NULL;
	TaskType type;
	int index;

	if (Parser::isPositiveInteger(desc))
	{
		unsigned int i = stoi(desc);
		if (i > 0 && i <= searchResultIndices.size()) {
			index = searchResultIndices[i-1];
			markedTask = TaskList::getTaskAt(index);
		}
	}
	else if (Parser::parseTaskTypeAndIndex(desc, type, index))
	{
		markedTask = TaskList::getTaskOfTypeAt(type, index);
	}
	else
	{
		int numResults = searchTasks(desc);
		if (numResults == 0) {
			result = "Task not found. \n";
			return -1;
		}
		else if (numResults == 1) {
			int index = searchResultIndices[0];
			markedTask = TaskList::getTaskAt(index);
		}
		else {
			result = "The candidate solutions are: \n";
			for (int i=0; i<numResults; i++)
			{
				int index = searchResultIndices[i];
				result += to_string(i+1) + ". " + TaskList::getTaskAt(index)->format() + "\n";
			}
			return SUCCESS;
		}
	}
	if (markedTask != NULL) {
		if (mark) {
			if (markedTask->markDone()) {
				saveFile();
				result = MESSAGE_MARK_DONE;

				History::storeAction(MARK,markedTask);
				return SUCCESS;
			}
			else {
				result = MESSAGE_ALR_DONE;
				return ERROR_PROCESSING_COMMAND;
			}
		}
		else {
			if(markedTask->markUndone()) {
				saveFile();
				result =MESSAGE_UNDONE_SUCCESS;

				History::storeAction(UNMARK,markedTask);
				return SUCCESS;
			}
		}
	}
	else {
		result = MESSAGE_NO_MATCH_RESULT;
		return ERROR_PROCESSING_COMMAND;
	}

	result = MESSAGE_UNKNOWN_ERROR;
	return ERROR_PROCESSING_COMMAND;
}
//@author A0096794H
int Logic::saveFile()
{
	FileProcessing::saveFile();
	return SUCCESS;
}

int Logic::displaySearchResults(string& results)
{
	results = "The results are:\n\n";
	int count = 1;
	for (unsigned int i=0; i<searchResultIndices.size(); i++) {
		int index = searchResultIndices[i];

		results += to_string(count) + ". ";
		results += TaskList::getTaskAt(index)->format();
		results += "\n";

		count++;
	}
	return SUCCESS;
}
//@author A0105566E
int Logic::searchTasks(string query)
{
	searchResultIndices.clear();	
	int numResults = 0;
	Date date = Parser::parseDate(query);
	Time time = Parser::parseTime(query);
	if (date != NULL_DATE)
		numResults = searchByDate(date);
	else if (time != NULL_TIME)
		numResults = searchByTime(time);
	numResults += searchByDesc(query);
	return numResults;
}
//@author A0105566E
int Logic::searchByDesc(string desc) {
	int size = TaskList::totalTaskCount();
	for (int i=0; i<size; i++)
	{
		string taskDesc = TaskList::getTaskAt(i)->getDescription();
		if(Parser::toLower(taskDesc).find(Parser::toLower(desc)) != string::npos)
		{
			searchResultIndices.push_back(i);
		}
	}
	return searchResultIndices.size();
}
//@author A0099619J
int Logic::searchByDate(Date date) {
	int size = TaskList::totalTaskCount();
	for (int i=0; i<size; i++)
	{
		Task* task = TaskList::getTaskAt(i);
		if(task->getTaskType() == DEADLINE && ((DeadlineTask*) task)->getDueDate() == date ||
		   task->getTaskType() == TIMED && ((TimedTask*)task)->getStartDate() <= date && ((TimedTask*)task)->getEndDate() >= date)
		{
			searchResultIndices.push_back(i);
		}
	}
	return searchResultIndices.size();
}

int Logic::searchByTime(Time time) {
	int size = TaskList::totalTaskCount();
	for (int i=0; i<size; i++)
	{
		Task* task = TaskList::getTaskAt(i);
		if(task->getTaskType() == DEADLINE && ((DeadlineTask*) task)->getDueTime() == time ||
		   task->getTaskType() == TIMED && ((TimedTask*)task)->getStartTime() == time ||
		   task->getTaskType() == TIMED && ((TimedTask*)task)->getEndTime() == time)
		{
			searchResultIndices.push_back(i);
		}
	}
	return searchResultIndices.size();
}
//@author A0096794H
void Logic::loadFile(){
	FileProcessing::loadFile();
}

void Logic::displayIndividualTask(Task* task, string& results ){
	stringstream ss;
	ss<<"This task contains the following information"<<endl<<endl;
	if(task==NULL)
	{
		ss<<"1. Description : NIL"<<endl;
	}
	else
		ss<<"1. Description  : "<<task->getDescription()<<endl;
	//case for 2nd parameter for task
	if(task==NULL||task->getTaskType()==FLOATING||(task->getTaskType()==DEADLINE))
	{
		ss<<"2. Starting Date: NIL"<<endl;
	}
	else if(task->getTaskType()==TIMED)
	{
		ss<<"2. Starting Date: "<<((TimedTask*)task)->getStartDate()<<endl;
	}
	//case for 3rd parameter
	if(task==NULL||task->getTaskType()==FLOATING||task->getTaskType()==DEADLINE||(task->getTaskType()==TIMED&&((TimedTask*)task)->getStartTime()==NULL_TIME))
	{
		ss<<"3. Starting Time: NIL"<<endl;
	}
	else if(task->getTaskType()==TIMED)
	{
		ss<<"3. Starting Time: "<<((TimedTask*)task)->getStartTime()<<endl;
	}
	//case for 4th parameter
	if(task==NULL||task->getTaskType()==FLOATING||(task->getTaskType()==DEADLINE&&(((DeadlineTask*)task)->getDueDate()==NULL_DATE))||(task->getTaskType()==TIMED&&(((TimedTask*)task)->getEndDate()==NULL_DATE)))
	{
		ss<<"4. Ending Date  : NIL"<<endl;
	}
	else if(task->getTaskType()==TIMED)
	{
		ss<<"4. Ending Date  : "<<((TimedTask*)task)->getEndDate()<<endl;
	}
	else if(task->getTaskType()==DEADLINE)
	{
		ss<<"4. Ending Date  : "<<((DeadlineTask*)task)->getDueDate()<<endl;
	}
	//case for 5th parameter
	if(task==NULL||task->getTaskType()==FLOATING||(task->getTaskType()==DEADLINE&&(((DeadlineTask*)task)->getDueTime()==NULL_TIME))||(task->getTaskType()==TIMED&&(((TimedTask*)task)->getEndTime()==NULL_TIME)))
	{
		ss<<"5. Ending Time  : NIL"<<endl;
	}
	else if(task->getTaskType()==TIMED)
	{
		ss<<"5. Ending Time  : "<<((TimedTask*)task)->getEndTime()<<endl;
	}
	else if(task->getTaskType()==DEADLINE)
	{
		ss<<"5. Ending Time  : "<<((DeadlineTask*)task)->getDueTime()<<endl;
	}
	//case for mark
	if(task->isDone())
	{
		ss<<"6. Task Status  : Completed"<<endl;
	}
	else
	{
		ss<<"6. Task Status  : Incomplete"<<endl;
	}
	if(task!=NULL)
	{
		ss<<"7. Done editing"<<endl;
		ss<<"8. Cancel/Exit Edit Mode"<<endl<<endl;
	}
	results=ss.str();
}
//@author A0105566E
int Logic::getTaskSummary(string& result) {
	int numTasks = TaskList::totalTaskCount();
	string overdueTasks = "Overdue Tasks:\n\n";
	string upcomingTasks = "Upcoming Tasks:\n\n";
	string inProgressTasks = "In Progress Tasks:\n\n";

	int overdueCount = 1;
	int upcomingCount = 1;
	int inProgressCount = 1;

	Date today = Date::getCurrentDate();
	Time now = Time::getCurrentTime();

	for (int i=0; i<numTasks; i++) {
		Task* task = TaskList::getTaskAt(i);
		if (task->isDone()) {
			continue;
		}

		if (task->getTaskType() == DEADLINE) {
			DeadlineTask* dTask = (DeadlineTask *) task;
			if (dTask->getDueDate() < today || dTask->getDueDate() == today && dTask->getDueTime() < now) {
				overdueTasks += dTask->format() += "\n";
			}
			else if (dTask->getDueDate() < today + 7) {
				upcomingTasks += dTask->format() += "\n";
			}
		}
		else if (task->getTaskType() == TIMED) {
			TimedTask* tTask = (TimedTask *) task;
			if (tTask->getEndDate() < today || tTask->getEndDate() == today && tTask->getEndTime() < now) {
				overdueTasks += tTask->format() += "\n";
			}
			else if (tTask->getStartDate() < today + 7) {
				upcomingTasks += tTask->format() += "\n";
			}
			else if(tTask->getStartDate()<today||tTask->getStartDate() == today && tTask->getStartTime() <now){
				if(tTask->getEndDate() > today || tTask->getEndDate() == today && tTask->getEndTime() > now)
				{
					inProgressTasks += tTask->format() += "\n";
				}
			}
		}
	}

	result = "\n" + overdueTasks + "\n\n" + inProgressTasks +"\n\n"+ upcomingTasks+"\n\n";

	return SUCCESS;
}
//@author A0096794H
void Logic::displayEditedTask(string desc,Date startDate,Time startTime,Date endDate,Time endTime,bool done,string& results) {
	stringstream ss;
	ss<<"This task contains the following information"<<endl<<endl;
	ss<<"1. Description  : "<<desc<<endl;
	ss<<"2. Starting Date: "<<startDate.formatDate()<<endl;
	ss<<"3. Starting Time: "<<startTime.formatTime()<<endl;
	ss<<"4. Ending Date  : "<<endDate.formatDate()<<endl;
	ss<<"5. Ending Time  : "<<endTime.formatTime()<<endl;
	if (done)
		ss<<"6. Task Status  : Completed"<<endl;
	else
		ss<<"6. Task Status  : Incomplete"<<endl;
	ss<<"7. Done editing"<<endl;
	ss<<"8. Cancel/Exit Edit Mode"<<endl<<endl;
	results=ss.str();
}

bool Logic::isValidTask(string desc,Date startDate,Time startTime,Date endDate,Time endTime,Task* &newTask)
{
	int markSD=0,markST=0,markED=0,markET=0;
	if(startDate.isValidDate())
		markSD=1;
	if(startTime.isValidTime())
		markST=1;
	if(endDate.isValidDate())
		markED=1;
	if(endTime.isValidTime())
		markET=1;

	if(markSD==0&&markST==0&&markED==0&&markET==0) {
		newTask = new FloatingTask(desc);
		return true;
	}
	else if(markSD==0&&markST==0&&markED==1&&markET==0)
	{
		newTask = new DeadlineTask(desc,endDate);
		return true;
	}
	else if(markSD==0&&markST==0&&markED==1&&markET==1)
	{
		newTask = new DeadlineTask(desc,endDate,endTime);
		return true;
	}
	else if(markSD==1&&markST==0&&markED==1&&markET==0)
	{
		newTask = new TimedTask(desc,startDate,endDate);
		return true;
	}
	else if(markSD==0&&markST==1&&markED==1&&markET==1)
	{
		newTask = new TimedTask(desc,endDate,startTime,endTime);
		return true;
	}
	else if(markSD==1&&markST==1&&markED==0&&markET==1)
	{
		newTask = new TimedTask(desc,startDate,startTime,endTime);
		return true;
	}
	else if(markSD==1&&markST==1&&markED==1&&markET==1)
	{
		newTask = new TimedTask(desc,startDate,startTime,endDate,endTime);
		return true;
	}
	else
		return false;
};

//@author A0105566E
void Logic::resetBuffer()
{
	searchResultIndices.clear();
}